package leets.leet2336;

import java.util.Stack;

public class Solution {
}
class SmallestInfiniteSet {
    int[] nums;
    int min=1;
    public SmallestInfiniteSet() {
        nums=new int[1001];
        nums[0]=-1;
    }

    public int popSmallest() {
        int lastMin=min;
        for (int i = min+1; i < nums.length; i++) {
            if (nums[i]!=-1){
                min=i;
                break;
            }
        }
        nums[lastMin]=-1;
        return lastMin;
    }

    public void addBack(int num) {
        if (num<min){
            min=num;
        }
        nums[num]=0;
    }
}

